package com.zmn.oms.task.listener;

import com.alibaba.fastjson.JSON;
import com.zmn.manager.mq.annotation.AliyunMQHandler;
import com.zmn.manager.mq.annotation.AliyunMQListener;
import com.zmn.oms.business.interfaces.work.OrderWorkBService;
import com.zmn.oms.business.interfaces.xno.OrderXnoBindBService;
import com.zmn.oms.business.interfaces.xno.OrderXnoBindService;
import com.zmn.oms.common.constant.MessageQueueTagConsts;
import com.zmn.oms.manager.utils.OmsMqTagConsts;
import com.zmn.oms.model.dto.work.xno.XnoUnBindDTO;
import com.zmn.oms.model.entity.detail.OrderDetail;
import com.zmn.oms.model.entity.work.OrderWork;
import com.zmn.oms.services.interfaces.detail.OrderDetailService;
import com.zmn.oms.services.interfaces.work.OrderWorkService;
import com.zmn.pay.gateway.common.model.dro.RefundResultDRO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName OrderWorkXnoUnbindListener
 * @description:
 * @author: wangyanci
 * @create: 2021-08-02 16:11
 * @Version 1.0
 **/
@AliyunMQListener(topic = "${spring.mq.topic.oms}")
@Component
@Slf4j
public class OrderWorkXnoUnbindListener {

    @Autowired
    private OrderXnoBindBService orderXnoBindBService;

    @AliyunMQHandler(tags = MessageQueueTagConsts.ORDER_XNO_UNBIND)
    public void xnoUnBind(String message) {
        log.info("com.zmn.oms.task.listener.OrderWorkXnoUnbindListener.xnoUnBind:{}", message);
        try {
            XnoUnBindDTO xnoUnBindDTO = JSON.parseObject(message, XnoUnBindDTO.class);
            orderXnoBindBService.unBind(xnoUnBindDTO);
        } catch (Exception e) {
            log.error("com.zmn.oms.task.listener.OrderWorkXnoUnbindListener.xnoUnBind error:{}", e.getMessage());
        }
    }

}